#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using ll=long long;
struct cmp{
	
	bool operator () (const pair<ll,ll>& p1,const pair<ll,ll>& p2){
		if(p1.first==p2.first){
			return p1.second>p2.second;
		}
		return p1.first<p2.first;	
	}
};


int main() {

	int n,m;
	cin>>n>>m;
	vector<ll> vecArr1(n),vecArr2(n);
	for(int i=0;i<n;++i){
		scanf("%lld",&vecArr1[i]);
	}
	for(int i=0;i<n;++i){
		scanf("%lld",&vecArr2[i]);
	}
	priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,cmp> q;
	
	for(int i=0;i<n;++i){
		q.push({vecArr2[i],vecArr1[i]});
	}
	ll llRet1=0,llRet2=0;
	while(m-->0 && q.size()){
		auto u=q.top();
		q.pop();
		//cout<<u.first<<' '<<u.second<<endl;
		llRet1+=u.first;
		llRet2+=u.second;
	}
	cout<<llRet2<<' '<<llRet1<<endl;
	
	return 0;
}
